package guoanmaker.operator.business.controller;



import javax.annotation.Resource;

  
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import guoanmaker.operator.business.service.OperatorBusinessService;
import guoanmaker.operator.helper.common.AjaxJson;
import guoanmaker.operator.helper.common.abstractobj.ApiController;
/**
 * 
 * @author zj
 *
 * 待审核商户
 *
 */
import io.swagger.annotations.ApiOperation;
@RestController
@RequestMapping(ApiController.OPERATOR_USER)
public class OperatorPendingMerchantController {
	
	@Resource
	private AjaxJson ajaxJson;
	
	@Resource
	private OperatorBusinessService  operatorBusinessService;
	
	/**
	 * 
	 * @param page
	 * @param size
	 * @param status  1----> 待审核    3----》已拒绝   2-----》已通过
	 * @return
	 */
	@ApiOperation(value = "待审核服务商户列表")
	@RequestMapping(value ="pendingMerchantList",method = RequestMethod.POST)
	public AjaxJson pendingMerchantList(@RequestParam(value = "page", defaultValue = "0") Integer page,
            @RequestParam(value = "size", defaultValue = "10") Integer size,Integer status){
		try {
			ajaxJson.setSuccess(true).setStatus(200).setMsg("操作成功").setData(operatorBusinessService.pendingMerchantList(page,size,status));
		} catch (Exception e) {
			ajaxJson.setSuccess(false).setStatus(500).setMsg("操作失败").setData("error");
		}
		return ajaxJson;
	}
	/**
	 * 
	 * @param id
	 * @param userid
	 * @return
	 */
	@ApiOperation(value = "审核服务商户")
	@RequestMapping(value ="auditbusiness",method = RequestMethod.POST)
	public AjaxJson auditbusiness(String id,String userid,Integer comCode){
		try {
			ajaxJson.setSuccess(true).setStatus(200).setMsg("操作成功").setData(operatorBusinessService.auditbusiness(id,userid,comCode));
		} catch (Exception e) {
			
			e.printStackTrace();
			ajaxJson.setSuccess(false).setStatus(500).setMsg("操作失败").setData("error");
		}
		return ajaxJson;
	}
	
 //审核商户基本信息
	@ApiOperation(value = "审核服务商户基本信息 和审核信息")
	@RequestMapping(value ="auditbusinessinfo",method = RequestMethod.POST)
	public  AjaxJson auditbusinessinfo(String id){
		try {
			ajaxJson.setSuccess(true).setStatus(200).setMsg("操作成功").setData(operatorBusinessService.auditbusinessinfo(id));
		} catch (Exception e) {
			ajaxJson.setSuccess(false).setStatus(500).setMsg("操作失败").setData("error");
		}
		return ajaxJson;
	}
	

	
	
	  
	//测试保存商户
	@ApiOperation(value = "审核服务商户基本信息 和审核信息")
	@RequestMapping(value ="savebusinessinfo",method = RequestMethod.POST)
	public  AjaxJson savebusinessinfo(String busnessname,String companyname){
		try {
			ajaxJson.setSuccess(true).setStatus(200).setMsg("操作成功").setData(operatorBusinessService.savebusinessinfo(busnessname,companyname));
		} catch (Exception e) {
			ajaxJson.setSuccess(false).setStatus(500).setMsg("操作失败").setData("error");
		}
		return ajaxJson;
	}
	/**
	 * 
	 * @param id
	 * @param content
	 * @param reason
	 * @param userid
	 * @return
	 */
	//拒绝商户
	@ApiOperation(value = "拒绝服务商")
	@RequestMapping(value ="refusebusiness",method = RequestMethod.POST)
	public  AjaxJson refusebusiness(String id,String content,String reason,String userid){
		try {
			ajaxJson.setSuccess(true).setStatus(200).setMsg("操作成功").setData(operatorBusinessService.refusebusiness(id,content,reason,userid));
		} catch (Exception e) {
			ajaxJson.setSuccess(false).setStatus(500).setMsg("操作失败").setData("error");
		}
		return ajaxJson;
	}
	
	
	//拒绝原因下拉选
	@ApiOperation(value = "拒绝原因下拉选")
	@RequestMapping(value ="refuseList",method = RequestMethod.POST)
	public  AjaxJson refuseList(){
		try {
			ajaxJson.setSuccess(true).setStatus(200).setMsg("操作成功").setData(operatorBusinessService.refuseList());
		} catch (Exception e) {
			ajaxJson.setSuccess(false).setStatus(500).setMsg("操作失败").setData("error");
		}
		return ajaxJson;
	}
	//测试保存拒绝原因
	@ApiOperation(value = "保存拒绝原因") 
	@RequestMapping(value ="saverefuse",method = RequestMethod.POST)
	public  AjaxJson saverefuse(String refuseName){
			try {
				ajaxJson.setSuccess(true).setStatus(200).setMsg("操作成功").setData(operatorBusinessService.saverefuse(refuseName));
			} catch (Exception e) {
				ajaxJson.setSuccess(false).setStatus(500).setMsg("操作失败").setData("error");
			}
			return ajaxJson;
		}
	
	//审批记录列表
	@ApiOperation(value = "审批记录列表") 
	@RequestMapping(value ="approrecords",method = RequestMethod.POST)
	public  AjaxJson approrecords(String id){
			try {
				ajaxJson.setSuccess(true).setStatus(200).setMsg("操作成功").setData(operatorBusinessService.approrecords(id));
			} catch (Exception e) {
				ajaxJson.setSuccess(false).setStatus(500).setMsg("操作失败").setData("error");
			}
			return ajaxJson;
		}
	
		
}
